package com.yitao.cms.controller.product;

import com.skipper.base.bean.DataOutput;
import com.skipper.base.bean.PagedOutput;
import com.yitao.client.dto.product.BuiltPlaceIconDto;
import com.yitao.cms.config.aopLog.LogAnnotation;
import com.yitao.cms.service.product.BuiltPlaceIconService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: wwl
 * @Date: 2019/6/26 18:04
 * @Description:
 */
@Api(value = "/cms/builtPlaceIcon", description = "产地图标数据", tags = {"cms-builtPlaceIcon"})
@RestController
@RequestMapping(value = "/builtPlaceIcon", produces = {"application/json"})
public class BuiltPlaceIconController {
    @Autowired
    private BuiltPlaceIconService builtPlaceIconService;

    @ApiOperation("新增/编辑产地，图标")
    @LogAnnotation(targetType = "builtPlaceIconSave", remark = "产地-图标新增/编辑")
    @RequestMapping(value = "/saveBuiltPlaceIcon", method = RequestMethod.POST)
    public DataOutput<BuiltPlaceIconDto> saveBuiltPlaceIcon(HttpServletRequest request,
                                                            @ApiParam(value = "id(编辑时传递)") @RequestParam(value = "id",required = false) Long id,
                                                            @ApiParam(value = "产地名") @RequestParam(value = "name") String name,
                                                            @ApiParam(value = "产地英文名") @RequestParam(value = "enName") String enName,
                                                            @ApiParam(value = "图标链接") @RequestParam(value = "icon") String icon) {
        return builtPlaceIconService.saveBuiltPlaceIcon(request, id, name, enName, icon);
    }

    @ApiOperation("查询产地信息列表")
    @RequestMapping(value = "/builtPlaceIconList", method = RequestMethod.POST)
    public PagedOutput<BuiltPlaceIconDto> builtPlaceIconList(
            @ApiParam(value = "id") @RequestParam(value = "id",required = false) Long id,
            @ApiParam(value = "产地名") @RequestParam(value = "name",required = false) String name,
            @ApiParam(value = "产地英文名") @RequestParam(value = "enName",required = false) String enName,
           // @ApiParam(value = "是否删除") @RequestParam(value = "isDelete",required = false) Boolean isDelete,
            @ApiParam(value = "分页参数，表示当前页", required = true, defaultValue = "1") @RequestParam(value = "pageNo") Integer pageNo,
            @ApiParam(value = "分页参数，表示每页显示多少条记录", required = true, defaultValue = "10") @RequestParam(value = "pageSize") Integer pageSize) {
        return builtPlaceIconService.builtPlaceIconList(id,name, enName,pageNo,pageSize);
    }
    @ApiOperation("查询产地信息")
    @RequestMapping(value = "/builtPlaceIconById", method = RequestMethod.POST)
    public DataOutput<BuiltPlaceIconDto> builtPlaceIconById(
            @ApiParam(value = "id") @RequestParam(value = "id",required = false) Long id) {
        return builtPlaceIconService.builtPlaceIconById(id);
    }
    @ApiOperation("修改删除状态")
    @LogAnnotation(targetType = "updateBuiltPlaceIconStatus", remark = "产地-图标删除状态")
    @RequestMapping(value = "/updateBuiltPlaceIconStatus", method = RequestMethod.POST)
    public DataOutput updateBuiltPlaceIconStatus(
            HttpServletRequest request,
            @ApiParam(value = "id") @RequestParam(value = "id",required = false) Long id) {
        return builtPlaceIconService.updateBuiltPlaceIconStatus(request,id);
    }
    @ApiOperation("查询产地信息列表(不分页)")
    @RequestMapping(value = "/builtPlaceIconListAll", method = RequestMethod.POST)
    public DataOutput<BuiltPlaceIconDto> builtPlaceIconList(
            @ApiParam(value = "产地名") @RequestParam(value = "name",required = false) String name,
            @ApiParam(value = "产地英文名") @RequestParam(value = "enName",required = false) String enName) {
        return builtPlaceIconService.builtPlaceIconListAll(name, enName);
    }

}
